﻿#include "my_table_widget.h"

void MyTableWidget::init(uint column_count_in,uint row_count_in)
{
	
    column_count = column_count_in;
    row_count    = row_count_in;
    setEnabled(true);
    setColumnCount(column_count);
    setRowCount(row_count);									// 设置列数
    horizontalHeader()->setVisible(false);				// 设置表头可见
    verticalHeader()->setVisible(false);				// 设置表头可见
    verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    setEditTriggers(QAbstractItemView::NoEditTriggers);		// 设置不可编辑
    setSelectionMode(QAbstractItemView::NoSelection);
}
void MyTableWidget:: setVertical(uint index,QStringList stringlist)
{
    for(int i=0;i<stringlist.size();i++)
    {
        if(i<row_count)
        {
            QTableWidgetItem * item = new QTableWidgetItem(stringlist.at(i));
            setItem(i,index, item);
        }
    }
}
